﻿using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace NS
{
    [HotUpdate]
    [Description("付款申请更新银行账号字段等相关信息")]
    public class updateFEACHBANKACCOUNT : AbstractOperationServicePlugIn
    {
        public override void OnPreparePropertys(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePropertysEventArgs e)
        {
            e.FieldKeys.Add("FID");
        }
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            foreach (DynamicObject item in e.DataEntitys)
            {
                string FID = "";
                if (item["ID"] != null && Convert.ToString(item["ID"]) != "")
                {
                    FID = Convert.ToString(item["ID"]);
                }
                string SQL = "/*dialect*/" + string.Format(@"UPDATE T SET T.FEACHBANKACCOUNT='',T.FBANKDETAIL=0 
                FROM T_CN_PAYAPPLYENTRY T
                LEFT JOIN T_CN_PAYAPPLY T2 ON T.FID=T2.FID
                WHERE T2.FID='{0}' AND T2.F_WNEG_COMBO='1'", FID);
                DBUtils.ExecuteDynamicObject(this.Context, SQL);
                string SQL0 = "/*dialect*/" + string.Format(@"UPDATE T SET T.FEACHCCOUNTNAME='',FEACHBANKNAME='' FROM T_CN_PAYAPPLYENTRY_L T
				LEFT JOIN T_CN_PAYAPPLYENTRY T1 ON T.FENTRYID=T1.FENTRYID
				LEFT JOIN T_CN_PAYAPPLY T2 ON T1.FID=T2.FID
                WHERE T2.FID='{0}' AND T2.F_WNEG_COMBO='1'", FID);
                DBUtils.ExecuteDynamicObject(this.Context, SQL0);
            }
        }
    }
}
